package com.zyht.bank.wechat.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.zyht.bank.entity.AxdInformationNotices;
import com.zyht.bank.entity.AxdInformationNoticesExample;
import com.zyht.bank.service.AxdInformationNoticesService;
import com.zyht.common.AbsPrintBaseController;

@Controller
@RequestMapping("anon/informationNotices")
public class AxdInformationNoticesController extends AbsPrintBaseController{
	
	@Resource
	private AxdInformationNoticesService  axdInformationNoticesService;
	
	@RequestMapping(value="list")
	public String list(
			Model model){
		//String wxid=getWxid();
		//LoginCookie cookie= getLoginCookie();
		//String actorNo = cookie.getActorNo();
		AxdInformationNoticesExample axdInformationNoticesExample = new AxdInformationNoticesExample();
		axdInformationNoticesExample.setOrderByClause("create_time DESC");
		axdInformationNoticesExample.createCriteria().andStatesEqualTo(1);
		List<AxdInformationNotices> list = axdInformationNoticesService.list(axdInformationNoticesExample);
	    model.addAttribute("list", list);

		return "banks/wechat/informationNotices/list";
	}
	
@RequestMapping(value="/detail")
	
	public String detail(@RequestParam(value = "id", required = true)Integer id,
			Model model){
		
		
	    AxdInformationNotices bean = axdInformationNoticesService.findOneById(id);
		/*LoginCookie cookie= getLoginCookie();
		SbeMemberExample sbeMemberExample = new SbeMemberExample();
		sbeMemberExample.createCriteria().andActorNoEqualTo(cookie.getActorNo()).andMobilePhoneEqualTo(cookie.getPhone());
		List<SbeMember> list = sbeMemberService.selectByExample(sbeMemberExample);*/
		//String collectionUrl="/ecitic/aticle/detail";
	    // collectionUrl+="?type="+type+"&id="+id;
		//String antNo=cookie.getActorNo();
		String summ = bean.getContent();
		if(summ !=null ){
			summ = summ.replaceAll("[\n|\t|\r]", "");
			bean.setContent(summ);
		}
		
		
		model.addAttribute("bean", bean);
		//记录阅读次数
		bean.setWatchTimes(bean.getWatchTimes()+1);
		axdInformationNoticesService.updateById(bean);
		//查询是否关注
		String isConcern = "0";
	/*	SbeMember member=null;
		LoginCookie login=getLoginCookie();
		SbeMemberExample abeexample = new SbeMemberExample();
		abeexample.createCriteria().andActorNoEqualTo(login.getActorNo()).andMobilePhoneEqualTo(login.getPhone());
		List<SbeMember> sblist=sbeMemberService.selectByExample(abeexample);
		if(sblist!=null&&sblist.size()==1){
			member=sblist.get(0);
		}
		SbeArticleConcernExample example = new SbeArticleConcernExample();
		example.createCriteria().andArticleidEqualTo(id).andMemberIdEqualTo(member.getId());
		List<SbeArticleConcern> conlist = sbeArticleConcernService.selectByExample(example);
		if (conlist.size() > 0){
			isConcern = "1";
		}*/
		model.addAttribute("isConcern", isConcern);
		return "banks/wechat/informationNotices/detail";
	}
	
	
	

}
